package com.test.nnooolwdeaer.dialog_wooden;

import android.annotation.SuppressLint;
import android.content.Context;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.Log;
import android.view.ViewGroup;
import android.widget.ListView;
import android.widget.TextView;

import androidx.annotation.NonNull;

import com.google.android.material.bottomsheet.BottomSheetDialog;
import com.test.nnooolwdeaer.R;
import com.test.nnooolwdeaer.adapter_wooden.CustomerServiceListAdapter_wooden;
import com.test.nnooolwdeaer.bean_wooden.config_info_wooden.AppShowInfo_wooden;

public class CustomerServiceDialog_wooden extends BottomSheetDialog {

    public CustomerServiceDialog_wooden(@NonNull Context context) {
        super(context,R.style.BottomSheetDialogStyle);
    }

    private int listHeight_wooden = 0;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.dialog_customer_service_wooden);
        initView_wooden();
    }

    @SuppressLint("SetTextI18n")
    private void initView_wooden(){

        getWindow().setBackgroundDrawableResource(R.color.trans);
        getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);

        findViewById(R.id.dialog_customer_service_ib_back).setOnClickListener(v -> dismiss());

        TextView descTv = findViewById(R.id.dialog_customer_tv_desc);
        String desc = AppShowInfo_wooden.getInstance().getCustomerDesc();
        if (!TextUtils.isEmpty(desc)){
            //tag2025
            Log.w("==desc", desc );

            descTv.setText(desc);
        }

        ListView listView = findViewById(R.id.dialog_customer_service_lv_list);
        CustomerServiceListAdapter_wooden customerServiceListAdapter = new CustomerServiceListAdapter_wooden(getContext());
        listView.setAdapter(customerServiceListAdapter);

        ViewGroup.LayoutParams layoutParams = listView.getLayoutParams();
        if (listHeight_wooden ==0) listHeight_wooden = layoutParams.height;
        layoutParams.height = customerServiceListAdapter.getCount()* listHeight_wooden;
        listView.setLayoutParams(layoutParams);

    }
}
